<template>
  <div class="about">
    <v-header />
    <v-sidebar @handleselect="handleselect" />
    <div class="content-box" :class="{ 'content-collapse': collapse }">
      <!-- <v-tags></v-tags> -->
      <div class="content">
        <router-view v-slot="{ Component }" :key="$route.fullPath">
          <transition name="move" mode="out-in">
            <keep-alive :include="tagsList">
              <component :is="Component" />
            </keep-alive>
          </transition>
        </router-view>
        <!-- <el-backtop target=".content"></el-backtop> -->
      </div>
    </div>
  </div>
</template>
<script>
import { computed } from "vue";
import { useStore } from "vuex";
import vHeader from "../components/Header.vue";
import vSidebar from "../components/Sidebar.vue";
import vTags from "../components/Tags.vue";
import api from "../api/api";
import router from "../router";
export default {
  components: {
    vHeader,
    vSidebar,
    vTags,
  },
  setup() {
    const store = useStore();
    const getuserinfo = async () => {
      console.log(localStorage.getItem("projectId"));
      api
        .postFormAPI("auth/user/info", {})
        .then((res) => {
          if (res.data.code == 1) {
            let projectList = res.data.data.projectList;
            if (projectList.length <= 1) {
              localStorage.setItem("projectId", projectList[0].id);
              console.log(localStorage.getItem("projectId"));
            }
          }
          //数据处理
        })
        .catch((err) => {
          console.log(err);
        });
    };
    getuserinfo();
    const tagsList = computed(() =>
      store.state.tagsList.map((item) => item.name)
    );
    const collapse = computed(() => store.state.collapse);
    const handleselect = (event) => {
      let url = "";
      if (event.indexOf("/engineeCollege") != -1) {
        url =
          "http://106.60.12.111:1662/thing/external/operation/poclogin?loginCode=admin&targetUrl=/thing/screen/index.html?name=工学院";
        window.open(url, "_blank");
      } else if (event.indexOf("/fudanHospital") != -1) {
        url =
          "http://106.60.12.111:1662/thing/external/operation/poclogin?loginCode=admin&targetUrl=/thing/screen/index.html?name=复旦中山厦门医院";
        window.open(url, "_blank");
      } else if (event.indexOf("/fudanHospital") != -1) {
        router.push("./digitalSupervision")
      }
    };
    return {
      tagsList,
      collapse,
      handleselect,
    };
  },
};
</script>
